#include<iostream>
#include<string.h>
#include<stdio.h>
#include<windows.h>
using namespace std;

typedef struct Word
{
	int num;
	char w[20];
	int s;
}Word;

int  chDeal(char *a,Word *word)
{
	char ch,word_temp[20]="";
	int i=0,j=0,k=0,key=0;
	while(a[i]!='\0')
	{
		ch=a[i];
		if((ch>='a'&&ch<='z')||(ch>='A'&&ch<='Z')||(ch>='0'&&ch<='9'))
		{
			 word_temp[key]=ch;//连续几个字母的连成单词
			 key++;
			 word_temp[key]='\0';
		}
		else
		{
			 if(strcmp(word_temp,"")!=0)
                {
                    strcpy(word[j].w,word_temp);//将单词拷贝到结构数组中
                     strcpy(word_temp,"") ;
                    key=0;//回到临时数组的开始位置
                    j++;//结构数组的下标加1
			 }
			if(ch==' '||ch=='	'||ch==10)
			{
				i++;
				continue;
			}
			else{
						if(ch=='"')
						{
							i++;
							for(key=0;a[i]!='"';i++,key++)
							{
								word_temp[key]=a[i];
							}
							word_temp[key]='\0';
							strcpy(word[j].w,word_temp);//将单词拷贝到结构数组中
							strcpy(word_temp,"");
							word[j].s=3;
							key=0;//回到临时数组的开始位置
							j++;//结构数组的下标加1
						}
						else	if(ch==39)
						{
							i++;
							for(;a[i]!=39;i++,key++)
							{
								word_temp[key]=a[i];
							}
							word_temp[key]='\0';
							strcpy(word[j].w,word_temp);
							strcpy(word_temp,"");
							word[j].s=2;
							key=0;
							j++;
						 }
						else	if(ch=='>'||ch=='<')
						{
							if(a[i+1]=='=')
							{
								word_temp[key++]=ch;
								word_temp[key++]=a[i+1];
								i++;
								word_temp[key]='\0';
							}
							else
							{
								 word_temp[0]=ch;
								word_temp[1]='\0';
							}
							strcpy(word[j].w,word_temp);
							strcpy(word_temp,"");
							key=0;
							j++;
						}
						else	 if(ch=='+'||ch=='-'||ch=='|'||ch=='&')
						{
								if(a[i+1]==ch)
							{
								word_temp[key++]=ch;
								word_temp[key++]=a[i+1];
								i=i++;
								word_temp[key]='\0';
							}
								else
								{
									 word_temp[0]=ch;
									word_temp[1]='\0';
								}
								strcpy(word[j].w,word_temp);
								strcpy(word_temp,"");
								key=0;
								j++;
						}
						else
					{
                    word_temp[0]=ch;
                    word_temp[1]='\0';//字符串结束符
                    strcpy(word[j].w,word_temp);//将非字母数字符号拷贝到结构数组中
                    strcpy(word_temp,"");
                    key=0;//回到临时数组的开始位置
                    j++;
                }
		}

		}
	i++;
	}
	 if(strcmp(word_temp,"")!=0)
                {
                    strcpy(word[j].w,word_temp);
                     strcpy(word_temp,"") ;
                    j++;
			 }
	return j;
}


void mateWord(Word *word,char ktt[][20],int i)
{
	int j,k;

	    for(j=0;j<i;j++)
    {
        for(k=0;k<41;k++)
        {
            if((strcmp(word[j].w,ktt[k]))==0)
            {
                if(k>=0&&k<16)
                    word[j].num=1;//保留字
                else if(k>=16&&k<25)
                    word[j].num=5;//分隔符
                else if(k>=25&&k<41)
                    word[j].num=4;//运算符
                break;
            }
            else
			{
				if(word[j].w[0]>='0' &&  word[j].w[0]<='9')
				{
                    word[j].num=3;//数字
				}
				else if(word[j].s==2)
				{
					word[j].num=6;//字符常量
				}
				else if(word[j].s==3)
				{
					word[j].num=7;//字符串
				}
				else
					word[j].num=2;//变量
			}
        }
    }
    for(j=0;j<i;j++)//按格式要求打印输出
    {
        cout<<"<"<<word[j].num<<","<<word[j].w<<">"<<endl;
    }
}
int main()
{
	char a[500];
	int i;
	Word word[200];
    char ktt[50][20]={"int","char","void","if","else","switch","case","default","do","main","if","while","break","continue","for","return",
    ",",";",":","(",")","[","]","{","}","+","-","*","/","=","<",">","<=",">=","++","--","%","!","||","==","!="};
	cout<<"please input"<<endl;
	gets(a);
	i=chDeal(a,word);
	mateWord(word,ktt,i);
	return 0;
}
